﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Ebada.Platform.Model;
using Ebada.UI.Base;
using Ebada.Client;
using Ebada.Core;
using Ebada.Client.Platform;


namespace Ebada.Modules.Document
{
    /// <summary>
    /// 库位选择器
    /// </summary>
    public partial class frmDocumentBookSeletr : FormBase
    {


        public frmDocumentBookSeletr() 
        {
            InitializeComponent();
        }
        public string DocBookID = "";
        public string DocBookName = "";
        private void frmDocumentPositionSeletr_Load(object sender, EventArgs e)
        {
            //IList<Documents> dp_list = MainHelper.PlatformSqlMap.GetList<DocumentPosition>("where 2>1 order by Org_ID");
            //treeList1.DataSource = dp_list;
            //Init_Org();
            IList<Documents> tempdoclist = MainHelper.PlatformSqlMap.GetList<Documents>(" where DocBookID!=''");
            Hashtable temphstable = new Hashtable();
            for (int i = 0; i < tempdoclist.Count; i++)
            {
                if (!temphstable.Contains(tempdoclist[i].DocBookID))
                {
                    temphstable.Add(tempdoclist[i].DocBookID.ToString(), tempdoclist[i].DocBookName.ToString());
                }
            }
            DataTable temptable = new DataTable();
            temptable.Columns.Add("DocBookID");
            temptable.Columns.Add("DocBookName");
            foreach (string  key in temphstable.Keys)
	        {
                  DataRow temprow = temptable.NewRow();
                temprow["DocBookID"]=key;
                temprow["DocBookName"]=temphstable[key].ToString();
                temptable.Rows.Add(temprow);
	        }
            gridControl1.DataSource= temptable;

         
            
        }
        /// <summary>
        /// 根据sqlwhere条件筛选数据
        /// </summary>
        /// <param name="sqlwhere"></param>
       
    
       
        private void btnOK_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
           
        }

        private void treeList1_DoubleClick(object sender, EventArgs e)
        {
            if (gridView1.GetFocusedDataRow()!=null)
            {
                DocBookID = gridView1.GetFocusedDataRow()["DocBookID"].ToString();
                DocBookName = gridView1.GetFocusedDataRow()["DocBookName"].ToString();

            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void gridView1_DoubleClick(object sender, EventArgs e)
        {
            if (gridView1.GetFocusedDataRow() != null)
            {
                DocBookID = gridView1.GetFocusedDataRow()["DocBookID"].ToString();
                DocBookName = gridView1.GetFocusedDataRow()["DocBookName"].ToString();

            }
            this.Close();
        }
       
       
    }
}